//package com.bauer.java.com.bauer.java.doc.pdf.text;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.itextpdf.text.Document;
//import com.itextpdf.text.com.bauer.java.doc.pdf.AcroFields;
//import com.itextpdf.text.com.bauer.java.doc.pdf.PdfCopy;
//import com.itextpdf.text.com.bauer.java.doc.pdf.PdfReader;
//import com.itextpdf.text.com.bauer.java.doc.pdf.PdfStamper;
//
//import java.io.ByteArrayOutputStream;
//import java.io.FileOutputStream;
//import java.util.Iterator;
//
///**
// * @Author ：rui.wei
// * @Date ：Created in 12:37 2019/3/6
// * @Description：
// */
//public class AddText {
//
//    public static void main(String[] args) throws Exception {
//
//        test1();
////        test2();
//    }
//
//    public static void test1() throws Exception {
//        String templeteFile = "F:\\learn\\java\\com.bauer.java.doc.pdf\\src\\main\\java\\com\\bauer\\java\\com.bauer.java.doc.pdf\\text\\12.com.bauer.java.doc.pdf";
//        String outFile = "F:\\learn\\java\\com.bauer.java.doc.pdf\\src\\main\\java\\com\\bauer\\java\\com.bauer.java.doc.pdf\\text\\13.com.bauer.java.doc.pdf";
//
//        String str = "{\"attached\":false,\"censusAddress\":\"江苏省南京市雨花区春江新城\",\"certNo\":\"110111197303221436\",\"channelMerchantAddr\":\"福建省泉州市鲤城区常泰街道下店社区南环路1195号三楼\",\"channelMerchantName\":\"泉州市桔子汽车贸易有限公司\",\"commonLesseeAddr\":\"江苏省南京市雨花区春江新城\",\"commonLesseeCert\":\"320882199104051000\",\"commonLesseeName\":\"铁蛋\",\"commonLesseePhoneNo\":\"15062201234\",\"contractNo\":\"L2019031048\",\"customerName\":\"壹二一65\",\"downPaymentAmount\":\"30500\",\"downPaymentAmountZh\":\"叁万零伍佰元整\",\"engineSerialNo\":\"12345678912345678\",\"extraGPSCostAmount\":\"500\",\"extraGPSCostAmountZh\":\"伍佰元整\",\"gatheringAccountName1\":\"泉州市天佳汽车服务有限公司\",\"gatheringAccountNo1\":\"***2928\",\"gatheringBank1\":\"泉州丰泽支行中国农业银行\",\"guaranteePerson1Addr\":\"江苏省南京市雨花区春江新城\",\"guaranteePerson1CertNo\":\"320882199104051000\",\"guaranteePerson1Name\":\"铁蛋\",\"guaranteePerson1PhoneNo\":\"15062201234\",\"guaranteePerson2Addr\":\"江苏省南京市雨花区软件大道156号\",\"guaranteePerson2CertNo\":\"123456789123456789\",\"guaranteePerson2Name\":\"米么金服\",\"guaranteePerson2PhoneNo\":\"025-9999999\",\"inAccountType\":\"一\",\"loanAmount\":\"150000\",\"loanAmountZh\":\"壹拾伍万元整\",\"merchantContactAddr1\":\"福建省泉州市丰泽区城东街道南埔社区华园南路博\",\"merchantName1\":\"泉州市天佳汽车服务有限公司\",\"name\":\"壹二一65\",\"newCarCheckMark\":\"✔\",\"operationPhoneNo1\":\"15659060888\",\"phoneNo\":\"15062201234\",\"sumTotal\":\"180000\",\"sumTotalZh\":\"壹拾捌万元整\",\"term\":3,\"termRepaymentAmount\":\"50919.46\",\"termRepaymentAmountZh\":\"伍万零玖佰壹拾玖元肆角陆分\",\"vehicleBrand\":\"长城\",\"vehicleColor\":\"12\",\"vehicleType\":\"H9\",\"vehicleVinNo\":\"12345678912345678\"}";
//        JSONObject jsonObject =  JSON.parseObject(str);
//        PDFUtils.fillParam(templeteFile, outFile, jsonObject);
//    }
//
//
//    public static void test2() throws Exception {
//        PdfReader pdfReader = new PdfReader(
//                "F:\\learn\\java\\com.bauer.java.doc.pdf\\src\\main\\java\\com\\bauer\\java\\com.bauer.java.doc.pdf\\text\\12.com.bauer.java.doc.pdf");
//        ByteArrayOutputStream bos = new ByteArrayOutputStream();
//        FileOutputStream out = new FileOutputStream(
//                "F:\\learn\\java\\com.bauer.java.doc.pdf\\src\\main\\java\\com\\bauer\\java\\com.bauer.java.doc.pdf\\text\\13.com.bauer.java.doc.pdf");
//        PdfStamper pdfStamper = new PdfStamper(pdfReader, bos);
//
//        String str = "{\"newCarCheckMark\":\"✔\",\"oldCarCheckMark\":\"\"}";
//
//
//        AcroFields form = pdfStamper.getAcroFields();
//        pdfStamper.setFormFlattening(true);
//        JSONObject jsonObject =  JSON.parseObject(str);
//        Iterator<String> keys = jsonObject.keySet().iterator();
//        while (keys.hasNext()){
//            String key = keys.next();
//            form.setField(key, jsonObject.getString(key));
//        }
//
//        pdfStamper.close();
//
//        Document doc = new Document();
//        PdfCopy copy = new PdfCopy(doc, out);
//        doc.open();
//        doc.newPage();
//        copy.addDocument(new PdfReader(bos.toByteArray()));
//        doc.close();
//    }
//}
